<cfoutput>
	<cfif IsUserLoggedIn() and IsDefined("request.scholar") and request.scholar.Scholarship_ID gt 0>
	
		<cfscript>
			scholarshipGateway = new assets.calgrants.com.gateway.ScholarshipGateway();
			scholarship = scholarshipGateway.get(Scholarship_ID = GetAuthUser());
			base = new assets.calgrants.com.Base();
			storedProcedureGateway = new assets.calgrants.com.gateway.StoredProcedureGateway();
			highSchools = storedProcedureGateway.call("getDistinctHighSchools");
			cities = storedProcedureGateway.call("getDistinctCities");
		</cfscript>
	
		<script type="text/javascript" language="javascript">
		<!--
			<cfoutput>
				var highSchoolID = "#scholarship.getHigh_School_ID()#";
				var city = "#scholarship.getCity()#";
				var cities = new kendo.data.DataSource();
				cities.data(#SerializeJSON(base.QueryToStruct(cities), false)#);
			</cfoutput>
			
			var toggleAsian = function() {
				if ($("##asian").is(":checked")) {
					$("##asianSubGroup").show();	
				} else {
					$("##asianSubGroup").hide();
					$(".asianSubGroup").prop("checked", false);
				}
			}
			
			var toggleIslander = function() {
				if ($("##islander").is(":checked")) {
					$("##islanderSubGroup").show();	
				} else {
					$("##islanderSubGroup").hide();
					$(".islanderSubGroup").prop("checked", false);
				}
			}
			
			var validate = function() {
				var errors = "";
				var valid = true;
				var dob = Date.parse($("##DOB").val());
				var date1960 = Date.parse("1/1/1960");
				if ($("##newHighSchoolID").is(":checked")) {
					if ($("##newHighSchool").val().length == 0) {
						valid = false;
						errors += "High School is required\n";
					}
					if ($("##newHighSchoolCity").val().length == 0) {
						valid = false;
						errors += "High School City is required\n";
					}
				}
				if (dob < date1960) {
					errors += "Date of Birth is invalid\n";
					valid = false;
				}
				if (!valid) {
					alert(errors);
				}
				return valid;		
			}
			
			var toggleHighSchool = function() {
				if ($("##newHighSchoolID").is(":checked")) {
					$("##highSchoolContainer").hide();
					$("##highSchoolFormContainer").show();
					$("##highSchoolID").val("0");	
				} else {
					$("##highSchoolFormContainer").hide();
					$("##highSchoolContainer").show();
					$("##newHighSchool").val("");
					$("##newHighSchoolCity").val("");
					$("##highSchoolID").val(highSchoolID);
				}
			}
			
			$(function() {
				if ($("##asian").is(":checked")) {
					$("##asianSubGroup").show();
				}
				if ($("##islander").is(":checked")) {
					$("##islanderSubGroup").show();
				}
				/*$("##highSchoolCB").kendoComboBox({
					dataTextField: "display",
					dataValueField: "high_school_id",
					dataSource: highSchools,
					filter: "contains",
					suggest: true,
					index: highSchoolIdx
				})*/
				$("##cityAC").kendoAutoComplete({
					minLength: 3,
					dataTextField: "city",
					dataSource: cities,
					filter: "contains",
					select: function(e) {
						$("##cityAC").blur();
						$("##cityAC").val(e.item[0].innerHTML);
						$("##cityAC").focus();
					}
				})
				$("##cityAC").val(city);
			})
		//-->
		</script>
		
		<cfform name="scholarProfileForm" id="scholarProfileForm" action="#script_name#" method="post" onsubmit="return validate();">
			<cfinput type="hidden" name="action" value="saveScholar" />
			<cfinput type="hidden" name="Scholarship_ID" value="#GetAuthUser()#" />
			<cfif IsDate(request.scholar.Claim_Date)>
				<cfinput type="hidden" name="view" value="#view#" />
			<cfelse>
				<cfinput type="hidden" name="view" value="editScholarInstitution" />
			</cfif>
			<div class="row">
				<div class="span6">
					<div class="clearfix">
						<label class="required">First Name</label>
						<cfinput type="text" name="First_Name" value="#scholarship.getFirst_Name()#" required="yes" message="First Name is required" maxlength="50" style="width: 350px;">
					</div>
					<div class="clearfix">
						<label class="required">Last Name</label>
						<cfinput type="text" name="Last_Name" value="#scholarship.getLast_Name()#" required="yes" message="Last Name is required" maxlength="50" style="width: 350px;">
					</div>
					<div class="clearfix">
						<label class="required">Permanent Address</label>
						<cfinput type="text" name="Address" value="#scholarship.getAddress()#" required="yes" message="Address is required" maxlength="200" style="width: 350px;">
					</div>
					<div class="kendo-control clearfix">
						<label class="required">City</label>
						<cfinput id="cityAC" name="City" value="#scholarship.getCity()#" required="yes" message="City is required" autocomplete="off" style="width: 350px;">
					</div>
					<div class="clearfix">
						<label class="required">Zip Code</label>
						<cfinput type="text" name="Zip_Code" value="#scholarship.getZip_Code()#" required="yes" message="Zip Code is required and must be a valid zip code" validate="zipcode" maxlength="5" style="width: 350px;" placeholder="##########">
					</div>
					<div class="clearfix">
						<label class="required">E-mail</label>
						<cfinput type="text" name="Email" value="#scholarship.getEmail()#" required="yes" message="E-mail is required and must be a valid e-mail address" validate="email" maxlength="100" style="width: 350px;">
					</div>
					<div class="clearfix">
						<label class="required">Password</label>
						<cfinput type="password" name="Password" value="#scholarship.getPassword()#" required="yes" message="Password is required" maxlength="50" style="width: 350px;">
					</div>
					<div class="clearfix">
						<label class="required">Home Phone</label>
						<cfinput type="text" name="Phone1" value="#scholarship.getPhone1()#" required="yes" message="Home Phone is required and must be a valid telephone number" maxlength="15" validate="telephone" style="width: 350px;" placeholder="######-######-########">
					</div>
					<div class="clearfix">
						<label class="required">Cell Phone</label>
						<cfinput type="text" name="Phone2" value="#scholarship.getPhone2()#" required="yes" message="Cell Phone is required and must be a valid telephone number" maxlength="15" validate="telephone" style="width: 350px;" placeholder="######-######-########">
					</div>
				</div>
				<div class="span6">
					<div class="clearfix">
						<label>Social Security Number, if you have one</label>
						<cfinput type="text" name="SSN" value="#scholarship.getSSN()#" required="no" message="Social Security Number must be a valid social security number" maxlength="15" validate="ssn" style="width: 350px;" placeholder="######-####-########">
					</div>
					<div class="clearfix">
						<label class="required">Date of Birth</label>
						<cfinput type="text" maxlength="10" name="DOB" value="#DateFormat(scholarship.getDOB(), 'm/d/yyyy')#" placeholder="m/d/yyyy" required="yes" validate="date" message="Date of Birth is required and must be a valid date" style="width: 100px;">
					</div>
					<div class="text-control clearfix">
						<label class="required">Gender</label>
						<label class="radio inline">
							<cfif scholarship.getGender() eq "M">
								<cfinput type="radio" name="Gender" value="M" checked="yes"> Male
							<cfelse>
								<cfinput type="radio" name="Gender" value="M"> Male
							</cfif>
						</label>
						<label class="radio inline">
							<cfif scholarship.getGender() eq "F">
								<cfinput type="radio" name="Gender" value="F" checked="yes"> Female
							<cfelse>
								<cfinput type="radio" name="Gender" value="F"> Female
							</cfif> 
						</label>
					</div>
					<!--- <cfif scholarship.getCohort() eq 5> --->
						<!--- <cfif Len(Trim(scholarship.getHigh_School())) eq 0> --->
							<div class="clearfix">
								<label class="required">High School</label>
								<label class="checkbox">
									<cfinput type="checkbox" id="newHighSchoolID" name="New_High_School_ID" value="0" onClick="toggleHighSchool();"> 
									My high school is not listed
								</label>
								<div id="highSchoolContainer" style="margin-top: 10px;">
									<cfselect id="highSchoolID" name="High_School_ID" required="yes" message="High School is required" style="width: 350px;">
										<option value="" selected>Select...</option>
										<cfloop query="highSchools">
											<option value="#High_School_ID#"<cfif scholarship.getHigh_School_ID() eq High_School_ID> selected</cfif>>#Display#</option>
										</cfloop>
										<cfif scholarship.getHigh_School_ID() eq 0 and Len(Trim(scholarship.getHigh_School())) gt 0>
											<option value="0" selected>#scholarship.getHigh_School()#</option>
										<cfelse>
											<option value="0">New high school</option>
										</cfif>
									</cfselect>
								</div>
								<div id="highSchoolFormContainer" style="display: none; margin-top: 10px;">
									<div class="clearfix">
										<label class="required">High School</label>
										<cfinput type="text" id="newHighSchool" name="New_High_School" value="" maxlength="200" style="width: 350px;">
									</div>
									<div class="clearfix">
										<label class="required">High School City</label>
										<cfinput type="text" id="newHighSchoolCity" name="New_High_School_City" value="" maxlength="200" style="width: 350px;">
									</div>
								</div>
							</div>
						<!--- <cfelse>
							<div class="text-control clearfix">
								<label class="required">High School</label>
								#scholarship.getHigh_School()#
							</div>
						</cfif> --->
					<!--- </cfif> --->
					<div class="clearfix">
						<label class="required">High School Graduation Date</label>
						<cfselect name="Graduation_Month" required="yes" message="Graduation Month is required" style="width: 150px;">
							<option value="">Select month...</option>
							<cfloop index="mo" from="1" to="12">
								<option value="#mo#"<cfif mo eq scholarship.getGraduation_Month()> selected</cfif>>#MonthAsString(mo)#</option>
							</cfloop>
						</cfselect>
						&nbsp;
						<cfif Len(Trim(scholarship.getGraduation_Year())) eq 0>
							#Year(Now())#
						<cfelse>
							#scholarship.getGraduation_Year()#
						</cfif>
						<!--- <cfselect name="Graduation_Year" required="yes" message="Graduation Year is required" style="width: 150px;">
							<option value="">Select year...</option>
							<cfloop index="yr" from="2009" to="#Year(Now())#">
								<option value="#yr#"<cfif yr eq scholarship.getGraduation_Year()> selected</cfif>>#yr#</option>
							</cfloop>
						</cfselect> --->
					</div>
					<div class="clearfix">
						<label class="required">Race/Ethnicity <small class="muted">(select all that apply)</small></label>
						<div class="well" style="margin-right: 20px;">
							<label class="checkbox">
								<input type="checkbox" name="Race_Ethnicity" value="American Indian or Alaskan Native" class="raceEthnicity"<cfif ListFindNoCase(scholarship.getRace_Ethnicity(), "American Indian or Alaskan Native", ",") gt 0> checked</cfif>> 
								American Indian or Alaskan Native
							</label>
							<label class="checkbox">
								<input type="checkbox" id="asian" name="Race_Ethnicity" value="Asian" class="raceEthnicity" onClick="toggleAsian();"<cfif ListFindNoCase(scholarship.getRace_Ethnicity(), "Asian", ",") gt 0> checked</cfif>> 
								Asian
							</label>
							<div id="asianSubGroup" style="display: none;">
								<blockquote>
									<label class="checkbox">
										<input type="checkbox" name="Race_Ethnicity" value="Asian Indian" class="asianSubGroup"<cfif ListFindNoCase(scholarship.getRace_Ethnicity(), "Asian Indian", ",") gt 0> checked</cfif>> 
										Asian Indian
									</label>
									<label class="checkbox">
										<input type="checkbox" name="Race_Ethnicity" value="Cambodian" class="asianSubGroup"<cfif ListFindNoCase(scholarship.getRace_Ethnicity(), "Cambodian", ",") gt 0> checked</cfif>> 
										Cambodian
									</label>
									<label class="checkbox">
										<input type="checkbox" name="Race_Ethnicity" value="Chinese" class="asianSubGroup"<cfif ListFindNoCase(scholarship.getRace_Ethnicity(), "Chinese", ",") gt 0> checked</cfif>> 
										Chinese
									</label>
									<label class="checkbox">
										<input type="checkbox" name="Race_Ethnicity" value="Filipino" class="asianSubGroup"<cfif ListFindNoCase(scholarship.getRace_Ethnicity(), "Filipino", ",") gt 0> checked</cfif>> 
										Filipino
									</label>
									<label class="checkbox">
										<input type="checkbox" name="Race_Ethnicity" value="Hmong" class="asianSubGroup"<cfif ListFindNoCase(scholarship.getRace_Ethnicity(), "Hmong", ",") gt 0> checked</cfif>> 
										Hmong
									</label>
									<label class="checkbox">
										<input type="checkbox" name="Race_Ethnicity" value="Japanese" class="asianSubGroup"<cfif ListFindNoCase(scholarship.getRace_Ethnicity(), "Japanese", ",") gt 0> checked</cfif>> 
										Japanese
									</label>
									<label class="checkbox">
										<input type="checkbox" name="Race_Ethnicity" value="Korean" class="asianSubGroup"<cfif ListFindNoCase(scholarship.getRace_Ethnicity(), "Korean", ",") gt 0> checked</cfif>> 
										Korean
									</label>
									<label class="checkbox">
										<input type="checkbox" name="Race_Ethnicity" value="Laotian" class="asianSubGroup"<cfif ListFindNoCase(scholarship.getRace_Ethnicity(), "Laotian", ",") gt 0> checked</cfif>> 
										Laotian
									</label>
									<label class="checkbox">
										<input type="checkbox" name="Race_Ethnicity" value="Vietnamese" class="asianSubGroup"<cfif ListFindNoCase(scholarship.getRace_Ethnicity(), "Vietnamese", ",") gt 0> checked</cfif>> 
										Vietnamese
									</label>
								</blockquote>
							</div>
							<label class="checkbox">
								<input type="checkbox" name="Race_Ethnicity" value="Black/African American" class="raceEthnicity"<cfif ListFindNoCase(scholarship.getRace_Ethnicity(), "Black/African American", ",") gt 0> checked</cfif>> 
								Black/African American
							</label>
							<label class="checkbox">
								<input type="checkbox" name="Race_Ethnicity" value="Hispanic/Latino" class="raceEthnicity"<cfif ListFindNoCase(scholarship.getRace_Ethnicity(), "Hispanic/Latino", ",") gt 0> checked</cfif>> 
								Hispanic/Latino
							</label>
							<label class="checkbox">
								<input type="checkbox" id="islander" name="Race_Ethnicity" value="Native Hawaiian or Other Pacific Islander" class="raceEthnicity" onClick="toggleIslander();"<cfif ListFindNoCase(scholarship.getRace_Ethnicity(), "Native Hawaiian or Other Pacific Islander", ",") gt 0> checked</cfif>> 
								Native Hawaiian or Other Pacific Islander
							</label>
							<div id="islanderSubGroup" style="display: none;">
								<blockquote>
									<label class="checkbox">
										<input type="checkbox" name="Race_Ethnicity" value="Guamanian" class="islanderSubGroup"<cfif ListFindNoCase(scholarship.getRace_Ethnicity(), "Guamanian", ",") gt 0> checked</cfif>> 
										Guamanian
									</label>
									<label class="checkbox">
										<input type="checkbox" name="Race_Ethnicity" value="Hawaiian" class="islanderSubGroup"<cfif ListFindNoCase(scholarship.getRace_Ethnicity(), "Hawaiian", ",") gt 0> checked</cfif>> 
										Hawaiian
									</label>
									<label class="checkbox">
										<input type="checkbox" name="Race_Ethnicity" value="Samoan" class="islanderSubGroup"<cfif ListFindNoCase(scholarship.getRace_Ethnicity(), "Samoan", ",") gt 0> checked</cfif>> 
										Samoan
									</label>
									<label class="checkbox">
										<input type="checkbox" name="Race_Ethnicity" value="Tahitian" class="islanderSubGroup"<cfif ListFindNoCase(scholarship.getRace_Ethnicity(), "Tahitian", ",") gt 0> checked</cfif>> 
										Tahitian
									</label>
								</blockquote>
							</div>
							<label class="checkbox">
								<input type="checkbox" name="Race_Ethnicity" value="White" class="raceEthnicity"<cfif ListFindNoCase(scholarship.getRace_Ethnicity(), "White", ",") gt 0> checked</cfif>> 
								White
							</label>
						</div>
					</div>
				</div>
			</div>
			<div class="row">
				<div class="span12">
					<div style="margin-bottom: 20px;">
						<cfif GetUserRoles() eq "scholar">
							<cfinput type="submit" name="saveButton" class="btn btn-primary" value="Save" />
						<cfelse>
							<a href="?view=scholarWelcome" class="btn btn-primary">Back</a>
							<button type="submit" name="continueButton" class="btn btn-primary">Continue</button>
						</cfif>
					</div>
				</div>
			</div>
		</cfform>
	<cfelse>
		<div class="row">
			<div class="span12">
				<div class="alert alert-info notFound">Scholarship not found</div>
			</div>
		</div>
	</cfif>
</cfoutput>